import axios from 'axios';
import env from '../config/env';
import $ from 'jquery';
window.$=$;

let util = {

};
util.title = function(title) {
    title = title ? title + ' - Home' : 'iView project';
    window.document.title = title;
};

const ajaxUrl = env === 'development' ?
    'http://127.0.0.1:8888' :
    env === 'production' ?
    'https://www.url.com' :
    'https://debug.url.com';

util.ajax = axios.create({
    baseURL: ajaxUrl,
    timeout: 30000
});

//util.baseURL = "http://127.0.0.1:7000/";
util.baseURL = "http://47.93.220.88:7000/"; //客户ip

//util.baseURL = "http://39.105.17.110:7000/";
/** 
util.request = function(params) {
    this.$http.post(util.baseURL+params.url,params.data,
        {emulateJSON: true})
        .then(
            (response)=>{
                params.sCallback && params.sCallback(response.data.data);
            },
            (error)=>{
                console.log(error);
            }
        )
}
*/
/** 
util.request = function(params) {
   
    var url = 'http://127.0.0.1:7001/';
    $.ajax(params.url, {

      data: params.data,

      dataType: 'json',
      type: params.type,
      crossDomain: true,

      success: function(data) {
        params.sCallback && params.sCallback(res.data);
      },

      error: function() {
          console.log("zjlzjl");
      }

    })

};
*/
export default util;